﻿using System;
class PrimeFactor
{
    private static bool isPrime(int n)
    {

        for (int i = 2; i < n /  2; i++)
        {
            if (n % i == 0)
                return false;
        }
        return true;
    }
    public static void Main()
    {
        int[] vs = new int[100];
        Console.WriteLine("请输入一个大于1的整数：");
        int num = Int32.Parse(Console.ReadLine());
        if (num < 2)
        {
            Console.WriteLine("输入不符要求");
        }
        else
        {
            Console.Write("素数因子是：");
            int count = 0, d = num;
            bool mulFactor = false, isFatcor = false;
            for(int i = 2; i <= d / 2; i++)
            {
                if (isPrime(i))
                {
                    while(num % i == 0)
                    {
                        num /= i;
                        isFatcor = true;
                        mulFactor = true;
                    }
                    if (isFatcor)
                    {
                        vs[count++] = i;
                        isFatcor = false;
                    }
                }
            }
            if (!mulFactor)
            {
                Console.WriteLine("1, {0}", num);
            }
            else
            {
                for (int i = 0; i + 1< count; i++)
                {
                    Console.Write("{0}, ", vs[i]);
                }
                Console.Write("{0}", vs[count - 1]);
            }
        }
    }
}
